<html>
<head><meta charset="utf-8"><title>dev-dependencies are just dependencies to RA, right? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html">dev-dependencies are just dependencies to RA, right?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="237887565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/237887565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#237887565">(May 07 2021 at 20:46)</a>:</h4>
<p>If I'm reading <a href="https://github.com/rust-analyzer/rust-analyzer/blob/ba8620398713d6f116dd1cce1a7e1cd6e3f97461/crates/project_model/src/cargo_workspace.rs#L300">https://github.com/rust-analyzer/rust-analyzer/blob/ba8620398713d6f116dd1cce1a7e1cd6e3f97461/crates/project_model/src/cargo_workspace.rs#L300</a> correctly, all of a crates deps are nodes in the dependency graph, and the <code>DependencyKind</code> distinction as determined by <code>cargo-metadata</code> is ignored.</p>
<p>And so when you're looking at a file, the symbols are coming from both the crate itself, and all of its <code>dependencies</code> and <code>dev-dependencies</code> from <code>Cargo.toml</code>?</p>



<a name="237887919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/237887919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#237887919">(May 07 2021 at 20:49)</a>:</h4>
<p>Yeah, this seems correct</p>



<a name="237887978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/237887978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#237887978">(May 07 2021 at 20:49)</a>:</h4>
<p>we actually want to do proper splitting of the crate into test and non-test in this sprint, but, IIRC, no one is actively working on it</p>



<a name="237890259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/237890259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#237890259">(May 07 2021 at 21:07)</a>:</h4>
<p>I took a brief look today but haven't made much progress</p>



<a name="237890317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/237890317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#237890317">(May 07 2021 at 21:08)</a>:</h4>
<p>(there's a very weird bug when using RA on rustc that I was hoping to fix with this, but I'm not sure it's the same one)</p>



<a name="238507079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238507079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238507079">(May 12 2021 at 16:49)</a>:</h4>
<p>haha..  And I have a change for GN to do the opposite in its <code>rust-project.json</code> generation that I've been working on:  combining the test and non-test <code>crate</code> entries together.</p>



<a name="238507251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238507251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238507251">(May 12 2021 at 16:50)</a>:</h4>
<p>Mostly because what we see is that the test-only deps all end up as unresolved symbols, as a source file gets mapped to the first-found crate entry, which is usually a non-test entry.</p>



<a name="238507343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238507343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238507343">(May 12 2021 at 16:51)</a>:</h4>
<p>But if there's work to support multiple "crates" per file, with different configs (at least for test), that's _great_, and I'll hold off any more work in that direction.</p>



<a name="238507741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238507741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238507741">(May 12 2021 at 16:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="301314">woody77</span> <a href="#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F/near/238507251">said</a>:</p>
<blockquote>
<p>Mostly because what we see is that the test-only deps all end up as unresolved symbols, as a source file gets mapped to the first-found crate entry, which is usually a non-test entry.</p>
</blockquote>
<p>we should fix this to choose the crate with the most enabled features (or some other heuristic)</p>



<a name="238507783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238507783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238507783">(May 12 2021 at 16:55)</a>:</h4>
<p>we'll need it when we instantiate a crate multiple times anyways</p>



<a name="238524308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238524308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238524308">(May 12 2021 at 18:44)</a>:</h4>
<p>I know <span class="user-mention" data-user-id="116114">@Paul Faria</span> has been thinking off and on about how to select a "configuration".</p>



<a name="238524686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238524686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238524686">(May 12 2021 at 18:46)</a>:</h4>
<p>TBH, our <code>rust-project.json</code> is unlikely to be what was really what was originally intended, as we often have 4 or more entries for the same <code>root_module</code> source file (<code>lib.rs</code> or <code>main.rs</code>):</p>
<ul>
<li>target</li>
<li>target unit-tests</li>
<li>host</li>
<li>host unit-tests</li>
</ul>



<a name="238524691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238524691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238524691">(May 12 2021 at 18:46)</a>:</h4>
<p>I should be getting more time to work on this starting next week. I've also started working on a doc to help align the questions and goals. I think I was trying to tackle too many problems at once the last time I worked on this</p>



<a name="238524995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238524995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238524995">(May 12 2021 at 18:48)</a>:</h4>
<p>The 4 targets above was what caused me a lot of trouble last time. It wasn't clear, given only a file path and a line, how to map which of the 4 crates above the query should be done against.</p>



<a name="238525290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238525290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238525290">(May 12 2021 at 18:50)</a>:</h4>
<p>And so one of my side investigations has been to take all ~5700 <code>crate</code> entries and combine the duplicate <code>root_modules</code> into the 3700 or so "crates" that RA is expecting.</p>



<a name="238525435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238525435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238525435">(May 12 2021 at 18:51)</a>:</h4>
<p>Also, RA, during initialization, only lists the unique <code>root_modules</code> when going through its "indexing" phase, not the full count of the <code>crate</code> entries.</p>



<a name="238526875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238526875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238526875">(May 12 2021 at 19:00)</a>:</h4>
<p>it should index all crates in the constructed crate graph</p>



<a name="238527001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/238527001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#238527001">(May 12 2021 at 19:00)</a>:</h4>
<p>there's now a "View Crate Graph" command, maybe that helps debug?</p>



<a name="241600235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/241600235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#241600235">(Jun 04 2021 at 22:28)</a>:</h4>
<p>One of the sources of duplication we have is that our build (and therefore our rust-project.json) is a mix of "host" and "target" compilation, using different arguments for rustc (different architectures, optimization, etc).</p>



<a name="241600295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies%20are%20just%20dependencies%20to%20RA%2C%20right%3F/near/241600295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/dev-dependencies.20are.20just.20dependencies.20to.20RA.2C.20right.3F.html#241600295">(Jun 04 2021 at 22:29)</a>:</h4>
<p>So there's a fair bit of duplication vs. what Cargo.toml contains.  and I've been sorting out how to best merge everything into fewer entries, that looks more like what RA expects from a Cargo.toml project)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>